package com.sys.service;

 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map; 
import javax.ejb.Stateless;  

import com.core.cache.AbstractStatementCache;
import com.core.cache.ConfileDbStatementCache; 
import com.core.cache.StatementCache;
import com.core.service.AbstractBaseService;
import com.sys.entity.TB_SYS_RULESCRIPT;
import com.sys.entity.TB_SYS_STATEMENT;
import com.sys.entity.TB_SYS_STATEMENT_INOUT;
import com.sys.entity.TB_SYS_STATEMENT_INOUT_VALUE; 
 

/**
 * Session Bean implementation class SVC_SYS
 */
@Stateless
public class SVC_SYS extends AbstractBaseService implements SVC_SYSRemote, SVC_SYSLocal {  

	@Override
	public Map ADD_SYS_STATEMENT(Map param) {  
		Map result = ADD(TB_SYS_STATEMENT.class, param); 
		return result;
	}

	@Override
	public Map UPD_SYS_STATEMENT(Map param) {  
		return UPD(TB_SYS_STATEMENT.class, param); 
	}

	@Override
	public void DEL_SYS_STATEMENT(Map param) {
		DEL(TB_SYS_STATEMENT.class, param); 
	}

	@Override
	public Map ADD_SYS_RULESCRIPT(Map param) {
		return ADD(TB_SYS_RULESCRIPT.class, param);
	}

	@Override
	public Map UPD_SYS_RULESCRIPT(Map param) {
		return UPD(TB_SYS_RULESCRIPT.class, param);
	}

	@Override
	public void DEL_SYS_RULESCRIPT(Map param) {
		DEL(TB_SYS_RULESCRIPT.class, param); 
	}
 

	@Override
	public List<HashMap<String, String>> getConfigMappers() {
		List<HashMap<String, String>> retList =  new ArrayList<HashMap<String,String>>();
		for(Map<String,StatementCache> mStaCach :AbstractStatementCache.getStatementcachecache().values()){
			for(StatementCache sc : mStaCach.values()){
				if(sc instanceof ConfileDbStatementCache){
					retList.addAll(((ConfileDbStatementCache)sc).getConfigMappers());
				}
			} 
		}
		return retList;
	}

	@Override
	public Map ADD_SYS_STATEMENT_INOUT(Map param) { 
		return ADD(TB_SYS_STATEMENT_INOUT.class,param);
	}

	@Override
	public Map UPD_SYS_STATEMENT_INOUT(Map param) {
		return UPD(TB_SYS_STATEMENT_INOUT.class,param);
	}

	@Override
	public void DEL_SYS_STATEMENT_INOUT(Map param) {
	 
		StringBuffer hql = new StringBuffer("delete from TB_SYS_STATEMENT_INOUT_VALUE o where INOUT_ID='").append(param.get("ID")).append("'");
	 
		doExecuteUpdate(hql.toString());
	
		DEL(TB_SYS_STATEMENT_INOUT.class,param);
	}

	@Override
	public Map ADD_SYS_STATEMENT_INOUT_VALUE(Map param) {
		return ADD(TB_SYS_STATEMENT_INOUT_VALUE.class,param);
	}

	@Override
	public Map UPD_SYS_STATEMENT_INOUT_VALUE(Map param) {
		return UPD(TB_SYS_STATEMENT_INOUT_VALUE.class,param);
	}

	@Override
	public void DEL_SYS_STATEMENT_INOUT_VALUE(Map param) {
		DEL(TB_SYS_STATEMENT_INOUT_VALUE.class,param);
	}  


}
